<!DOCTYPE HTML>
<html lang="cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <%include("/common/header.html",{title:''}){}%>
    <title>施工团队</title>
    <style>
    </style>
</head>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=IENn7ABARjQIkTeAKyh80VTkg2jYXf3K"></script>
<body>


<div class="x-nav" style="margin: 20px auto auto 15px;">
      <span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
        <a href="javascript:">首页</a><span lay-separator="">/</span>
        <a href="javascript:">施工团队</a><span lay-separator="">/</span>
        <a><cite>团队管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="margin: -5px 14px 0px 0px;float:right;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3"></i>
    </a>
</div>
<!--设备信息列表-->
<div class="x-body" style="margin: 20px auto auto 15px;">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <a href="javascript:" class="layui-btn layui-btn-warm">施工队伍管理</a>
        </div>
    </div>
    <div style="margin-left: -15px;" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <select type="text" name="t_name" id="t_name1" autocomplete="off" class="layui-select">
                </select>
            </div>
            <div class="layui-input-inline">
                <button  class="layui-btn layui-btn-checked" lay-submit="" lay-filter="LAY-user-front-search"  ><i class="layui-icon layui-icon-search"></i>查询</button>
            </div>
        </div>
    </div>

    <div class="layui-table-main layui-form" style="height: 100%">
        <table id="myTableData" lay-filter="myTableData"  class="layui-hide"></table>
        <div id="test1"></div>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card">
        <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
        <script type="text/html" id="toolbarDemo">
            <a class="layui-btn layui-btn layui-btn-sm"  lay-event="add"><i class="layui-icon layui-icon-add-1"></i>添加队伍</a>
        </script>
        <script type="text/html" id="table-useradmin-webuser">
            {{#  if(d.t_code==0){ }}
            <a style="margin: auto 40px;" class="layui-btn layui-bg-green layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
            {{#  }else if(d.t_code==1){ }}
            <a style="margin-left: 10px;" class="layui-btn layui-bg-green layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
            <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="set"><i class="layui-icon layui-icon-user"></i>设置账号</a>
            {{#  } }}
        </script>
    </div>
</div>
<!-- 弹出施工团队页面 -->
<div class="layui-form" lay-filter="layuiadmin-form-useradmin"
     id="layuiadmin-form-useradmin"
     style="padding: 15px;display: none">
    <form action class="layui-form" lay-filter="component-form-element" id="myform">
        <input type="hidden" name="id" id="id">
        <input type="hidden" name="t_code" id="t_code">
        <input type="hidden"  value="${session.om_user.enterprise.id}" id="e_id" name="e_id">
        <input type="hidden"  value="${session.om_user.sysRole.sysRoleCode.id}" id="role_id">
        <h2>基本信息</h2><hr />
        <div class="layui-form-item">
            <div class="layui-col-md6" style="float: left">
                <label class="layui-form-label">*队伍名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="t_name" id="t_name" lay-verify="required" autocomplete="off" placeholder="请输入队伍名称..." class="layui-input">
                </div>
            </div>

            <div class="layui-col-md6" style="float: left">
                <label class="layui-form-label">*负责人：</label>
                <div class="layui-input-block">
                    <input type="text" name="t_user" id="t_user" lay-verify="required" autocomplete="off" placeholder="请输入负责人..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6" style="float: left">
                <label class="layui-form-label">*联系电话：</label>
                <div class="layui-input-block">
                    <input type="text" name="t_phone" id="t_phone" lay-verify="required|phone" autocomplete="off" placeholder="请输入联系电话..." class="layui-input">
                </div>
            </div>

            <div class="layui-col-md6" style="float: left">
                <label class="layui-form-label">*队伍介绍：</label>
                <div class="layui-input-block">
                    <input type="text" name="t_introduce" id="t_introduce" lay-verify="required" autocomplete="off" placeholder="请输入队伍介绍..." class="layui-input">
                </div>
            </div>
        </div>

        <h2>人员信息</h2><hr />
        <div class="layui-form-item">
            <div class="layui-col-md6" style="float: left">
                <label style="width: 26%;padding-right: 0px;" class="layui-form-label">*男工人数（60岁以下）：</label>
                <div style="width: 71%;margin-left: 29%;" class="layui-input-block">
                    <input type="text" name="t_count_male1" id="t_count_male1" lay-verify="required|number" autocomplete="off" placeholder="请输入男工人数（60岁以下）..." class="layui-input">
                </div>
            </div>

            <div class="layui-col-md6" style="float: left">
                <label style="width: 26%;padding-right: 0px;" class="layui-form-label">*男工人数（60岁以上）：</label>
                <div style="width: 71%;margin-left: 29%;" class="layui-input-block">
                    <input type="text" name="t_count_male2" id="t_count_male2" lay-verify="required|number" autocomplete="off" placeholder="请输入男工人数（60岁以上）..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6" style="float: left">
                <label style="width: 26%;padding-right: 0px;" class="layui-form-label">*女工人数（55岁以下）：</label>
                <div style="width: 71%;margin-left: 29%;" class="layui-input-block">
                    <input type="text" name="t_count_female1" id="t_count_female1" lay-verify="required|number" autocomplete="off" placeholder="请输入女工人数（55岁以下）..." class="layui-input">
                </div>
            </div>

            <div class="layui-col-md6" style="float: left">
                <label style="width: 26%;padding-right: 0px;" class="layui-form-label">*女工人数（55岁以上）：</label>
                <div style="width: 71%;margin-left: 29%;" class="layui-input-block">
                    <input type="text" name="t_count_female2" id="t_count_female2" lay-verify="required|number" autocomplete="off" placeholder="请输入女工人数（55岁以上）..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6" style="float: left">
                <label style="width: 26%;padding-right: 0px;" class="layui-form-label">*团队最大人数：</label>
                <div style="width: 71%;margin-left: 29%;" class="layui-input-block">
                    <input type="text" name="t_count" id="t_count" lay-verify="required|number" autocomplete="off" placeholder="请输入团队最大人数..." class="layui-input">
                </div>
            </div>
        </div>

        <h2>人员详细信息</h2><hr />
        <div id="detailed" class="layui-form-item"></div>
        <div  style="margin-top: 20px">
            <button id="add" type="button" class="layui-btn" >+添加人员信息</button>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;margin-top: 200px;margin-left: -45px;">
                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">立即提交</button>
            </div>
        </div>
    </form>
</div>
<!--弹出添加管理员页面-->
<div class="layui-form" lay-filter="layuiadmin-form-useradmin"
     id="layuiadmin-form-useradmin1"
     style="padding: 15px;display: none">
    <form action class="layui-form" lay-filter="component-form-element1" id="formId">
        <input type="hidden"  value="${session.om_user.enterprise.id}" name="e_id">
        <input type="hidden"  value="" name="team_id" id="team_id">
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label">*账号：</label>
                <div class="layui-input-block" style="width: 100%;">
                    <input type="text" name="phone" lay-verify="required" autocomplete="off" placeholder="请输入账号..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label">*密码：</label>
                <div class="layui-input-block" style="width: 100%;">
                    <input type="text" name="passWord" lay-verify="required" autocomplete="off" placeholder="请输入密码..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label">*真实姓名：</label>
                <div class="layui-input-block" style="width: 100%;">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入真实姓名..." class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">*项目区域：</label>
            <div class="layui-input-inline" style="height: 40px;width: 130px">
                <select lay-filter="project" lay-verify="required" style="height: 40px;width: 30px" class="" name="projectid" id="project">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="layui-input-inline" style="height: 40px;width: 130px" id="www">
                <select lay-filter="area"  lay-verify="required" style="height: 40px;width: 30px" class="" name="areaid" id="areaid">
                    <option value="" >请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="zzz">
            <label class="layui-form-label">*绿地：</label>
            <div class="layui-input-inline" id="greenland"></div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 250px;margin-top: 200px;">
                <button class="layui-btn" lay-submit="" lay-filter="component-form-element1">立即提交</button>
            </div>
        </div>
    </form>
</div>

<script id="demo1" type="text/html">
    <option value="">请选择</option>
    {{#  layui.each(d.list1, function(index, item1){ }}

    <option value="{{ item1.id }}">{{ item1.projectName }}</option>

    {{#  }); }}
    {{#  if(d.list1.length === 0){ }}
    <div style="color: red;margin-top: 10px;">该账号暂无项目信息</div>
    {{#  } }}
</script>
<script id="demo2" type="text/html">
    <option value="" >请选择</option>
    {{#  layui.each(d.list2, function(index, item2){ }}

    <option value="{{ item2.id }}">{{ item2.projectName }}</option>

    {{#  }); }}
    {{#  if(d.list2.length === 0){ }}
    <option value="">无数据</option>
    {{#  } }}
</script>
<script id="demo3" type="text/html">
    {{#  layui.each(d.list3, function(index, item3){ }}

    <div>
        <input class="layui-input" lay-verify="required" type="checkbox" name="greenlandid" value="{{ item3.id }}">{{ item3.greedLandAdministrator.name }}
    </div>

    {{#  }); }}
    {{#  if(d.list3.length === 0){ }}
    <div style="color: red;margin-top: 10px;">暂无此区域绿地数据</div>
    {{#  } }}
</script>
<script id="demo4" type="text/html">
    <option value="">请选择施工队</option>
    {{#  layui.each(d.list4, function(index, item4){ }}

    <option value="{{ item4.t_name }}">{{ item4.t_name }}</option>

    {{#  }); }}
    {{#  if(d.list4.length === 0){ }}
    无数据
    {{#  } }}
</script>
<%include("/common/foot.html"){}%>
<script>
    //添加员工信息增加表单
    var num=0;
    $("#add").click(function() {
        num++;
        $("#detailed").append(
            "<div id='div"+num+"'><button onclick='deldiv("+num+")' style='float: left;width: 23px;margin-top: 8px;' type='button' class='layui-col-md1 layui-btn layui-btn-xs layui-btn-danger layui-btn-radius'><i class='layui-icon layui-icon-subtraction'></i></button><div class='layui-col-md4' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*员工姓名：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><input id='name"+num+"'  type='text' class='layui-input' lay-verify='required' placeholder='请输入员工姓名'></div></div>" +
            "<div class='layui-col-md3' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*性别：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><select id='sex"+num+"' style='display: block;width: 100%;' class='layui-select' lay-verify='required'><option value='男'>男</option><option value='女'>女</option></select></div></div>" +
            "<div class='layui-col-md4' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*员工年龄：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><input id='age"+num+"'  type='text' class='layui-input' lay-verify='required|number' placeholder='请输入员工年龄'></div></div><hr style='background-color: #fff0;'></div>"
        );
    });
    //删除人员信息
    function deldiv(num){
        $("#div"+num).remove();
    }

    layui.use(['index', 'table', 'form', 'laydate', 'layedit', 'AjaxCommon', 'AliangLayui'], function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var AjaxCommon = layui.AjaxCommon;
        var AliangLayui = layui.AliangLayui;

        var title = "修改团队信息";
        var title2 = "设置管理员";
        var findAll_url = 'system/constructionTeam/findAll.json';
        var update_url = 'system/constructionTeam/update.json';
        var setAdmin_url = 'system/constructionTeam/setAdmin.json';
        var delete_url = 'system/constructionTeam/delete.json';
        var cols = [ //设备信息列表表头
            /*{checkbox: true, fixed: true},*/

            {field: 't_name', fixed: 'left', sort:'true' , title: '队伍名称',},
            {
                field: '',
                sort:'true',
                templet: "<div>{{d.t_count_male1+d.t_count_male2+d.t_count_female1+d.t_count_female2}}</div>",
                title: '人数',
            },
            {field: 't_user', sort:'true' ,  title: '负责人',},
            {field: 't_phone',  title: '联系电话',},
            {
                field: 't_createDate',

                templet: "<div>{{layui.util.toDateString(d.t_createDate, 'yyyy-MM-dd ')}}</div>",
                title: '时间',
            },
            {title: '操作', fixed: 'right', width:250, toolbar: '#table-useradmin-webuser',}
        ];
        //施工队伍列表
        AliangLayui.createTable(
            "#LAY-user-manage",
            "listReload",
            "#toolbarDemo",
            title,
            findAll_url,
            true,
            [10, 15, 20, 25],
            ['filter', 'print', 'exports'],
            cols,
            {e_id:$("#e_id").val()}
        );
        //搜索栏队伍
        var eid = $("#e_id").val();
        var roleid = $("#role_id").val();
        $.ajax({
            url: "system/constructionTeam/findAreaTeam.json",
            type: "POST",
            data: {
                eid:eid,
                roleid:roleid
            },
            dataType: "json",
            success: function (ret4) {
                var laytpl = layui.laytpl;
                var rets = { //数据
                    "list4": ret4.data,
                };
                laytpl($("#demo4").html()).render(rets, function (html) {
                    $("#t_name1").html(html);
                });
                form.render();
            },
            error: function (jqXHR, textStatus, errorThrown) {

            }
        });

        //初始化施工队伍列表修改页面
        function loadData(data) {
            var ret = {
                "id": data.id,
                "t_name": data.t_name,
                "t_user": data.t_user,
                "t_phone": data.t_phone,
                "t_introduce": data.t_introduce,
                "t_count_male1": data.t_count_male1,
                "t_count_male2": data.t_count_male2,
                "t_count_female1": data.t_count_female1,
                "t_count_female2": data.t_count_female2,
                "t_code": data.t_code,
                "t_count": data.t_count
            };
            $.ajax({
                url: "system/constructionTeam/findMember.json",
                type: "POST",
                data: {
                    tid: data.id
                },
                dataType: "json",
                success: function (ret) {
                    num = 0;
                    if(ret.data.length>0){
                        for(var i =0; i<ret.data.length; i++){
                            num++;
                            $("#detailed").append(
                                "<div id='div"+num+"'><button onclick='deldiv("+num+")' style='float: left;width: 23px;margin-top: 8px;' type='button' class='layui-col-md1 layui-btn layui-btn-xs layui-btn-danger layui-btn-radius'><i class='layui-icon layui-icon-subtraction'></i></button><div class='layui-col-md4' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*员工姓名：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><input id='name"+num+"' type='text' class='layui-input' lay-verify='required' placeholder='请输入员工姓名'></div></div>" +
                                "<div class='layui-col-md3' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*性别：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><select id='sex"+num+"' style='display: block;width: 100%;' class='layui-select' lay-verify='required'><option value='男'>男</option><option value='女'>女</option></select></div></div>" +
                                "<div class='layui-col-md4' style='float: left'><label style='width: 20%;padding-right: 0px;' class='layui-form-label'>*员工年龄：</label><div style='width: 71%;margin-left: 25%;' class='layui-input-block'><input id='age"+num+"'  type='text' class='layui-input' lay-verify='required|number' placeholder='请输入员工年龄'></div></div><hr style='background-color: #fff0;'></div>"
                            );
                            $("#name"+num).val(ret.data[i].m_name);
                            $("#sex"+num).val(ret.data[i].m_sex);
                            $("#age"+num).val(ret.data[i].m_age);
                        }
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
            return ret;
        }

        //初始化日期模块
        laydate.render({
            elem: '#createDate' //指定元素
        });

        //弹出修改页面调用初始化数据方法
        function initUpdate(data) {
            var a = layer.open({
                type: 1,
                title: title,
                content: $('#layuiadmin-form-useradmin'),
                btn: [], //可以无限个按钮
                area:["600px","600px"],
                cancel: function (index, layero) {//取消事件
                    location.replace(location.href);　//layer.open关闭刷新
                },
                success: function (layero, index) {
                    layer.iframeAuto(index);
                }
            });
            layer.full(a);//layer全屏
            //如果是添加则重置表单，如果是编辑则给表单赋值
            if (data == 0 || data == null) {
                $("#id").val("");
                // $('#myform')[0].reset();

            } else {
                layui.form.val("component-form-element", loadData(data));
            }

        }

        //监听搜索
        form.on('submit(LAY-user-front-search)', function(data) {
            var field = data.field;
            //执行重载
            table.reload('listReload', {
                where :{
                    t_name:field.t_name
                },
                page: {
                    curr: 1//重新从第 1 页开始
                }
            });
        });

        //修改施工团队页面的内容提交到后台处理
        form.on('submit(component-form-element)', function (data) {
            let a = parseInt(data.field.t_count_male1);
            let b = parseInt(data.field.t_count_male2);
            let c = parseInt(data.field.t_count_female1);
            let d = parseInt(data.field.t_count_female2);
            let i = a+b+c+d;
            let count = $("#t_count").val();
            if(i>count){
                layer.msg("员工人数不得大于团队最大人数");
            }else{
                postUpdate(data);
            }
            return false;
        });
        //添加管理员页面的内容提交到后台处理
        form.on('submit(component-form-element1)', function (data) {

            //序列化表单方法
            $.fn.ghostsf_serialize = function () {
                var a = this.serializeArray();
                var $radio = $('input[type=radio],input[type=checkbox]', this);
                var temp = {};
                $.each($radio, function () {
                    if (!temp.hasOwnProperty(this.name)) {
                        if ($("input[name='" + this.name + "']:checked").length == 0) {
                            temp[this.name] = "";
                            a.push({name: this.name, value: ""});
                        }
                    }
                });
                console.log(JSON.stringify(a));
                return a;
            };

            var names = document.getElementsByName("greenlandid");
            var flag = false ;//标记判断是否选中一个
            for(var i=0;i<names.length;i++){
                if(names[i].checked){
                    flag = true ;
                    break ;
                }
            }
            if(!flag){
                layer.msg('请选择绿地<br>如所在区域下无绿地，您将不能开设施工账号', {
                    time: 0, //不自动关闭
                    btn: [ '确认']
                });
                return false ;
            }

            var formObject = {};
            var formArray =$("#formId").ghostsf_serialize();
            $.each(formArray,function(i,item){
                formObject[item.name] = item.value;
            });
            var greenland =[];
            $("input[name=greenlandid]:checked").each(function(index,itme){
                greenland.push(itme.value)
            });
            formObject["greenlandid"]=greenland.toString();
            postUpdate1(formObject);
            return false;
        });
        //头工具栏事件
        table.on('toolbar(LAY-user-manage)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'add':
                    initUpdate(0);
                    break;
                case 'delete':
                    var data = checkStatus.data;
                    if (data.length > 0) {
                        //var id = new Array(); //声明数组
                        for (var i in data) {
                            var a = data[i].id; //得到复选框的值
                            postDelete(a);
                        }
                    } else {
                        layer.msg("至少选择一个进行删除");
                    }
                    break;
                case 'export':
                    layer.msg("导出");
                    break;
            }
        });

        //点击每行右工具栏“操作”里面按钮效果
        table.on('tool(LAY-user-manage)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('删除以后数据将不能恢复，确定删除吗？', function(index) {
                    postDelete(data.id);
                });
            }else if (obj.event === 'edit') {
                initUpdate(data);
            }else if (obj.event === 'set') {
                $("#team_id").val(data.id);
                //弹出添加施工帐号页面
                var b = layer.open({
                    type: 1,
                    title: title2,
                    content: $('#layuiadmin-form-useradmin1'),
                    btn: [], //可以无限个按钮
                    area:["600px","600px"],
                    cancel: function (index, layero) {//取消事件
                        location.replace(location.href);　//layer.open关闭刷新
                    },
                    success: function (layero, index) {
                        layer.iframeAuto(index);
                        $("#www").hide();
                        $("#zzz").hide();
                        $.ajax({
                            url: "system/constructionTeam/findProject.json",
                            type: "POST",
                            data:{
                                e_id:data.e_id
                            },
                            dataType: "json",
                            success: function(ret){
                                var laytpl = layui.laytpl;
                                var data = { //数据
                                    "list1": ret.data
                                };
                                laytpl($("#demo1").html()).render(data, function (html) {
                                    $("#project").html(html);
                                });
                                form.render();

                            },
                            error:function(jqXHR, textStatus, errorThrown){

                            }
                        });

                        var e_id = $("#e_id").val();
                        form.on('select(project)', function (data) {
                            var area=data.value;
                            area = area.replace("\"","").replace("\"","");
                            var areaid = parseInt(area);
                            $.ajax({
                                url: "system/constructionTeam/findArea.json",
                                type: "POST",
                                data:{
                                    areaid:areaid,
                                    e_id:e_id
                                },
                                dataType: "json",
                                success: function(ret){
                                    var laytpl = layui.laytpl;
                                    var data = { //数据
                                        "list2": ret.data,
                                    };
                                    laytpl($("#demo2").html()).render(data, function (html) {
                                        $("#areaid").html(html);
                                    });
                                    $("#www").show();
                                    form.render();
                                },
                                error:function(jqXHR, textStatus, errorThrown){

                                }
                            });
                        });

                        form.on('select(area)', function (data) {
                            if(data.value==""){
                                layer.msg('该区域下暂无绿地信息', {
                                    time: 0, //不自动关闭
                                    btn: [ '确认']
                                });
                                return false ;
                            }else{
                                var area=data.value;
                                area = area.replace("\"","").replace("\"","");
                                var areaid = parseInt(area);
                                $.ajax({
                                    url: "system/constructionTeam/findGreenland.json",
                                    type: "POST",
                                    data:{
                                        areaid:areaid
                                    },
                                    dataType: "json",
                                    success: function(ret){
                                        var laytpl = layui.laytpl;
                                        var data = { //数据
                                            "list3": ret.data,
                                        };
                                        laytpl($("#demo3").html()).render(data, function (html) {
                                            $("#greenland").html(html);
                                        });
                                        $("#zzz").show();
                                        form.render('checkbox');
                                    },
                                    error:function(jqXHR, textStatus, errorThrown){

                                    }
                                });
                            }
                        });
                    }
                });
                // layer.full(b);//layer全屏
            }
        });


        //ajax提交删除内容
        window.postDelete = function (id) {
            AjaxCommon.ajax(delete_url, "post", "json", {"id": id}, function (ret) {
                if (ret == null) {
                    layer.msg("删除失败", {
                        icon: 5
                    });
                } else {
                    layer.msg(ret.msg, {time: 600, icon: 6}, function () {
                        location.replace(location.href);
                    });
                    layer.closeAll();
                    // table.reload('listReload');
                }
                return ret;
            });
        };

        //ajax提交施工团队修改内容
        window.postUpdate = function (data) {
            var formData = new FormData();
            let names=[];
            for (let k = 1; k <=num; k++) {
                if($("#name"+k+"").val()!=undefined){
                    names.push($("#name"+k+"").val());
                }
            }

            let sexs=[];
            for (let ks = 1; ks <=num; ks++) {
                if($("#sex"+ks+"").val()!=undefined){
                    sexs.push($("#sex"+ks+"").val());
                }
            }

            let ages=[];
            for (let kss = 1; kss <=num; kss++) {
                if($("#age"+kss+"").val()!=undefined){
                    ages.push($("#age"+kss+"").val());
                }
            }

            let count1 = $("#t_count").val();
            if(names.length>count1){
                layer.msg("人员详细信息总数不得大于团队最大人数");
            }else{
                formData.append("data", JSON.stringify(data.field));
                formData.append("names", names);
                formData.append("sexs", sexs);
                formData.append("ages", ages);
                $.ajax({
                    url: update_url,
                    type: "POST",
                    //traditional:true,
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function (data) {
                        if (data.code == 0) {
                            layer.closeAll();
                            layer.msg(data.msg, {time: 600, icon: 1}, function () {
                                location.replace(location.href);
                            });
                        } else {
                            layer.msg(data.msg, {icon: 5});
                        }
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        var estr = "Page:" + window.location.pathname + ",Function:postUpdate()";
                        layer.open({
                            title: "错误信息",
                            type: 2,
                            content: "base/error.jhtml?info=" + estr,
                            btn: ['关闭'] //可以无限个按钮
                        });
                    }
                });
            }
        };

        //ajax提交添加管理员内容
        window.postUpdate1 = function (data) {
            var formData = new FormData();

            formData.append("data", JSON.stringify(data));
            $.ajax({
                url: setAdmin_url,
                type: "POST",
                //traditional:true,
                data: formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    if (data.code == 0) {
                        layer.closeAll();
                        layer.msg(data.msg, {time: 600, icon: 1}, function () {
                            location.replace(location.href);
                        });
                    } else if(data.code ==1){
                        layer.msg(data.msg, {
                            time: 0, //不自动关闭
                            btn: [ '确认']
                        });
                        // layer.msg(data.msg, {icon: 5});
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    var estr = "Page:" + window.location.pathname + ",Function:postUpdate()";
                    layer.open({
                        title: "错误信息",
                        type: 2,
                        content: "base/error.jhtml?info=" + estr,
                        btn: ['关闭'] //可以无限个按钮
                    });
                }
            });
        }
    });

</script>

</body>

</html>
